var editMenuModify = {
    init: function () {
        this.editSelectInteraction = new ol.interaction.Select()
        map.addInteraction(this.editSelectInteraction)
        this.editModifyInteraction = new ol.interaction.Modify({
            features: this.editSelectInteraction.getFeatures()
        })
        map.addInteraction(this.editModifyInteraction)
        this.setEvents()
    },
    setEvents: function () {
        var selectedFeatures = this.editSelectInteraction.getFeatures()
        this.editSelectInteraction.on('change:active', function () {
            selectedFeatures.forEach(selectedFeatures.remove, selectedFeatures)
        })
    },
    setActive: function (active) {
        removeInteractions()
        this.editSelectInteraction.setActive(active)
        this.editModifyInteraction.setActive(active)
    },
    run: function () {
        this.init()
        this.setActive(true)
    },
    disable: function () {
        this.setActive(false)
    }
}

function currentFeature() {
    return editMenuModify.editSelectInteraction.getFeatures().getArray()[0].getGeometry()
}

function saveEdit() {
    if (!queryMapGISCurrentFeature) return
    console.log(queryMapGISCurrentFeature)

    var featureObj = currentFeature()
    let pl = new Zondy.Object.Polygon()
    pl.setByOL(featureObj)
    let pol = new Zondy.Object.FeatureGeometry()
    pol.fGeom = queryMapGISCurrentFeature.fGeom
    pol.fGeom.RegGeom[0].Rings[0].Arcs[0].Dots = pl.pointArr

    if (featureObj != null) {
        var attValue = queryMapGISCurrentFeature.AttValue
        var newFeature = new Zondy.Object.Feature({AttValue: attValue, fGeom: pol.fGeom})
        newFeature.setFType(queryMapGISCurrentFeature.ftype)
        newFeature.setFID(queryMapGISCurrentFeature.FID)

        //创建一个要素数据集
        var featureSet = new Zondy.Object.FeatureSet()
        featureSet.TotalCount = 1
        var fldNumber = queryMapGISResultFeatureSet.AttStruct.FldNumber
        var fldType = queryMapGISResultFeatureSet.AttStruct.FldType
        var fldName = queryMapGISResultFeatureSet.AttStruct.FldName
        featureSet.AttStruct = new Zondy.Object.CAttStruct({FldNumber: fldNumber, FldType: fldType, FldName: fldName})
        featureSet.addFeature(newFeature)
        console.log(featureSet)

        var editDocFeature = new Zondy.Service.EditDocFeature(place.name, getLayerNumberFromLayUI(), siteConfig)
        editDocFeature.update(featureSet, res => {
            if(res.toString()=="true")alert("修改成功")
        }, err => {
            console.log(err)
        })
    }
}
